package so.wy.servicecenter.businessbed.api.order;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import so.wy.servicecenter.base.exception.WebException;
import so.wy.servicecenter.base.frame.api.httpexception.HttpExceptionHandler;
import so.wy.servicecenter.base.frame.baseopt.BaseOptHttp;
import so.wy.servicecenter.base.frame.baseopt.BaseOptWeb;
import so.wy.servicecenter.businessbed.service.order.dto.OrderDTO;
import so.wy.servicecenter.businessbed.web.order.OrderWeb;

/**
* @author wdl
* @date 2020-04-08
*/
@RestController
@Scope("request")
@RequestMapping("/order")
public class OrderHttp extends BaseOptHttp<OrderDTO>  {
    @Autowired
    private OrderWeb orderWeb;

	@Override
    protected BaseOptWeb getOptWeb() {
        return orderWeb;
    }

    @HttpExceptionHandler
    @GetMapping("/token")
    public String getRentUserOrders(Integer curPage, Integer pageSize) throws WebException {
	    return toHttpJson(orderWeb.getRentUserOrders(getUserId(),curPage,pageSize));
    }

    @HttpExceptionHandler
    @GetMapping("/details/serial")
    public String getOrderInfoBySerial(String orderSerial){
	    return toHttpJson(orderWeb.getOrderInfoBySerial(orderSerial));
    }
}